package com.zbu.system.controller.question;

import com.zbu.common.core.comtroller.BaseController;
import com.zbu.common.core.domain.R;
import com.zbu.common.core.domain.TableDataInfo;
import com.zbu.system.domain.question.Question;
import com.zbu.system.domain.question.dto.QuestionAddDTO;
import com.zbu.system.domain.question.dto.QuestionEditDTO;
import com.zbu.system.domain.question.dto.QuestionQueryDto;
import com.zbu.system.domain.question.vo.QuestionDetailVO;
import com.zbu.system.domain.question.vo.QuestionVO;
import com.zbu.system.service.question.IQuestionService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/question")
@Tag(name="题目管理")
public class QuestionController extends BaseController {
    @Autowired
    private IQuestionService iQuestionService;
    @GetMapping("/list")
    public TableDataInfo list(QuestionQueryDto questionQueryDto){
        List<QuestionVO>questionVOList= iQuestionService.list(questionQueryDto);
        return getTableDataInfo(questionVOList);
    }
    @PostMapping("/add")
    public R<Void> add(@RequestBody QuestionAddDTO questionAddDTO){
        return toR(iQuestionService.add(questionAddDTO));
    }
    @GetMapping("/detail")
    public R<QuestionDetailVO> detail(Long questionId){
        return R.ok(iQuestionService.detail(questionId));
    }
    @PutMapping("/edit")
    public R<Void>edit(@RequestBody QuestionEditDTO questionEditDTO){
        return toR(iQuestionService.edit(questionEditDTO));
    }
    @DeleteMapping("/delete")
    public R<Void>delete(Long questionId){
        return toR(iQuestionService.delete(questionId));
    }
}
